<#assign renderStatus = false>
<#assign showButton = false>
<#assign isShowedButton = false>
<#assign statusContent = ''>
<#assign showQueryDiv = false>
<#assign menuDivNumber = 0>
<#assign selectedItemNames = ''>
<#assign selectedNodes = ''>
<#assign isJunitTest=false>
<script type="text/javascript" src="./../script/plugins/highchar/highcharts.js"></script>
<script type="text/javascript" src="./../script/page/config/tab_vol.js"></script>
<link type="text/css" rel="stylesheet" href="./../script/plugins/popWindow/style/win.css" />
<script type="text/javascript" src="./../script/plugins/popWindow/script/Dean.library.js" ></script>
<script type="text/javascript" src="./../script/plugins/popWindow/script/windows.js" ></script>
<style type="text/css">
.statistic_comment{
	color:red;
}
.time_box{
	width:90px 
}
</style>
<form id="searchForm" action="/business/process?tdqssid=<%=session.getId()%>" onSubmit="return false">
<input type="hidden" id="businessProcessId" name="businessProcess.id" value="${businessProcess.id}">
<input type="hidden" id="id" name="id">
<input type="hidden" id="status" name="taskStatus">
<#if statistic.linkOperate??>
<input type="hidden" id="linkOperate" name="linkOperate" value="${statistic.linkOperate}"> 
</#if>
<#if !statistic.isTree?? || statistic.isTree == "0">
<#if statistic_list??>
<#assign menuDivNumber=menuDivNumber+1>
<div id="outer_tabs" class="ui-tabs ui-widget ui-widget-content" style="position:absolute;top:0px;padding:0px;border:0px;overflow:hidden;width:100%;">
	<ul class="ui-tabs-nav ui-widget-header">
		<#list statistic_list as item>
		<li id="${item.id}" itemid="${item.id}" itemfunid="<#if item.fromFunction??>${item.fromFunction.id}<#else> </#if>" <#if statistic.id?? && statistic.id==item.id> class="ui-state-default ui-state-active tab_selected selectedTab" style='<#else> class="ui-state-default ui-corner-top" style='</#if> display:inline;cursor:pointer;font-size:12px;font-weight: bold; color: #122664;border-bottom:0'>
			<#if statistic.id?? && statistic.id==item.id>
				<div class="leftBorder" style="font-size: 1px;position:relative;background-image:url('./../theme/default/images/main/tab_left_down.png');float:left;left:0px;width:3px;height:26px"></div>
				<div class="contentInner"  style="padding: 0px;line-height:14px;height:25px;position:relative;float:left;border-top:1px solid #2b729a;background-image:url('./../theme/default/images/main/tabs_down.png');">
					<a href="javascript:void(0)" onclick="clickStatistic('${item.id}');return false;"><span style="cursor:pointer;color:#ffffff" >${item.name}</span></a>
				</div>
				<div class="rightBorder" style="font-size: 1px;position:relative;background-image:url('./../theme/default/images/main/tab_right_down.png');float:left;right:0px;width:3px;height:26px">&nbsp;&nbsp;&nbsp;</div>
			<#else>
				<div class="leftBorder" style="font-size: 1px;position:relative;background-image:url('./../theme/default/images/main/tab_left.png');float:left;left:0px;width:3px;height:26px"></div>
				<div class="contentInner"  style="padding: 0px;line-height:14px;height:25px;position:relative;float:left;border-top:1px solid #c2e2eb;background-image:url('./../theme/default/images/main/tabs.png');">
					<a href="javascript:void(0)" onclick="clickStatistic('${item.id}');return false;"><span style="cursor:pointer;color:#122664" >${item.name}</span></a>
				</div>
				<div class="rightBorder" style="font-size: 1px;position:relative;background-image:url('./../theme/default/images/main/tab_right.png');float:left;right:0px;width:3px;height:26px">&nbsp;&nbsp;&nbsp;</div>
			</#if>
			
		</li>
		</#list>
	</ul>
</div>
</#if>
</#if>
<#if !statistic.isTree?? || statistic.isTree == "0">
			<#if statistic_list??>
            <div id="search_area" style="width:100%;position:absolute;top:30px;color:#122664;z-index:100">
            <#else>
            <div id="search_area" style="width:100%;position:absolute;top:0px;color:#122664;z-index:100">
            </#if>
                    	<#list query_field_list as queryField>
                            <#if queryField.hidden?? && queryField.hidden=="1">
                            <#else>
	                           	<#assign showQueryDiv=true>
                            </#if>
                    	</#list>
            			<#if !showQueryDiv>
	                        <div id="queryForm" style="background-image:url(/PNPMS/theme/default/images/main/seach_area_bg.png);float:left;width:100%;height:31px;display:none;">
	                    <#else>         
	                        <#assign menuDivNumber=menuDivNumber+1> 
	                        	<div id="queryForm" style="background-image:url(/PNPMS/theme/default/images/main/seach_area_bg.png);float:left;width:100%;height:32px;border:1px solid #96d0d2;">
                        </#if>

                        	<#if !showQueryDiv>
	                        	<div style="display:none;position:relative;float:left;">
                        	</#if>
                        	
	                        <div style="position:relative;float:left;">
	                        	<table cellspacing="0" cellpadding="0" style="line-height:33px;*line-height:32px;">
			                        <tr>
			                            <#list query_field_list as queryField>
			                                <#if queryField.hidden?? && queryField.hidden=="1">
			                                    ${queryField.content?default('')}
			                                <#else>
				                                <#if  queryField.type?? &&queryField.type != "3">
				                                	<#assign showButton=true>
					                                        <td class="textColor" style="padding-left:15px;">
					                                        ${queryField.field.displayName?default(queryField.field.desc)}：
					                                        </td>
					                                        <td class="elementColor">
					                                        ${queryField.content}
					                                        </td>
				                                <#else>
				                                	<#assign renderStatus = true>
				                                	<#assign statusContent = queryField.content>
				                                </#if>
			                                </#if>
			                            </#list>
	                            	</tr>
			                    </table>
		                    </div>
                            <#if !showQueryDiv>
                            </div>
                            </#if>

                        	<#if showButton >
                               	<#assign isShowedButton=true>
                        		<div style="position:relative;float:right;top:0px;right:3px">
									<table cellspacing="0" cellpadding="0">
									 	<tr>				
											<td>
	                        					<div class="searchButtonBox">
	                        					
	                        					<a href="#" class="button" tabindex="-1">
		                        					<div style="position:relative;float:right;border-left:1px solid #96d0d2;border-right:1px solid #96d0d2;">
			                        					<img id="commonSearch_img" src="./../theme/default/images/main/search/normal.png" style="position:absolute;top:6px">
			                        					<input id="search" type="button" value="统计" style="margin-top:0px" onClick="">
		                        					</div>
	                        					</a>
	                        					
	                        					</div>
	                        				</td>
										</tr>
									</table>
								</div>
                        	</#if>
						</div>
            			
                        <#if statistic.statisticType?? && statistic.statisticType=='2'>
                        <#assign menuDivNumber=menuDivNumber+1>
                        <#if (menuDivNumber == 1 || menuDivNumber == 2) && statistic_list??>
                        	<div id="queryForm1" style="background-image:url(/PNPMS/theme/default/images/main/seach_area_bg.png);float:left;width:100%;height:32px;border:1px solid #96d0d2">   
                        <#elseif !statistic_list?? && menuDivNumber == 2>
                        	<div id="queryForm1" style="background-image:url(/PNPMS/theme/default/images/main/seach_area_bg.png);float:left;width:100%;height:32px;border:1px solid #96d0d2;border-top:0px"> 
                        <#elseif !statistic_list?? && menuDivNumber == 1>
                        	<div id="queryForm1" style="background-image:url(/PNPMS/theme/default/images/main/seach_area_bg.png);float:left;width:100%;height:32px;border:1px solid #96d0d2">
                        <#else>
                        	<div id="queryForm1" style="background-image:url(/PNPMS/theme/default/images/main/seach_area_bg.png);float:left;width:100%;height:32px;border:1px solid #96d0d2;border-top:0px"> 
                        </#if>    
	                    
	                        	<div style="position:relative;float:left;">
		                        		<div style="position:relative;float:left;">
		                        		<table cellspacing="0" cellpadding="0" style="line-height:33px;*line-height:32px;">
			                            	<tr>
			                               	<#assign showButton=true>
											<td class="textColor" style="padding-left:15px;">第一维度：</td>
											<#if dimension_list??>
												<td class="elementColor">
												<select class="statisticElementColor" name="statistic.pageValues.firstDimesionId" id="firstWeb" onchange="firstWebfun()">
												<option value="">无</option> 
												<#list dimension_list as dimesion>
													<option value=${dimesion.id} <#if statistic.pageValues?? && statistic.pageValues.firstDimesionId?? && statistic.pageValues.firstDimesionId==dimesion.id>selected</#if>>${dimesion.name}</option>
											    </#list>
											    </select>
											    </td>
											</#if>
											<td class="textColor" style="padding-left:15px;">第二维度：</td>
											<#if dimension_list??>
												<td class="elementColor">
												<select class="statisticElementColor" name="statistic.pageValues.secondDimesionId" id="secondWeb" onchange="secondWebfun()">
												<option value="">无</option> 
												<#list dimension_list as dimesion>
													<option value=${dimesion.id} <#if statistic.pageValues?? && statistic.pageValues.secondDimesionId?? && statistic.pageValues.secondDimesionId==dimesion.id>selected</#if>>${dimesion.name}</option>
											    </#list>
											    </select>
											    </td>
											</#if>
											<td class="elementColor">
											<select class="statisticElementColor" name="statistic.pageValues.layoutType" id="secondLayout">
												<option value="1" <#if statistic.pageValues?? && statistic.pageValues.layoutType?? && statistic.pageValues.layoutType=='1'>selected</#if>>纵向</option>
												<option value="2" <#if statistic.pageValues?? && statistic.pageValues.layoutType?? && statistic.pageValues.layoutType=='2'>selected</#if>>横向</option>
											</select>
											</td>
											<#if dimension_list?? && dimension_list?size gt 2>
												<td class="textColor" style="padding-left:15px;">第三维度：</td>
												<#if dimension_list??>
													<td class="elementColor">
													<select class="statisticElementColor" name="statistic.pageValues.thirdDimesionId" id="thirdWeb">
													<option value="">无</option> 
													<#list dimension_list as dimesion>
														<option value=${dimesion.id} <#if statistic.pageValues?? && statistic.pageValues.thirdDimesionId?? && statistic.pageValues.thirdDimesionId==dimesion.id>selected</#if>>${dimesion.name}</option>
												    </#list>
												    </select>
												    </td>
												</#if>
											</#if>
											<#if item_list??>
												<td class="textColor" style="padding-left:15px;">统计项：</td>
												<td class="elementColor">
													<input type="text" readonly="readonly" id="statisticObj" name="statisticObj" class="textTest" value="请选择统计项" /> 
												<#assign a=0>
												<div id="DropdownMenu" class="dropDD_contentDiv">
													<div style="overflow:auto;height:266px">
														<label style="color:#122664;cursor:pointer;" for="selectAllItemID"><input type="checkbox" AutoPostBack="true" onclick="selectedItem(this)" id="selectAllItemID" name="selectAllItemName" >全选</input></label>
														<br>
														<#list item_list as item>
															<label style="color:#122664;cursor:pointer;" for="${item.id}"><input type="checkbox" AutoPostBack="true" onclick="itemChanged(this)" name="statistic.pageValues.selectedItemList" value="${item.id}" id="${item.id}" itemname="${item.name}"
															<#if statistic.pageValues?? && statistic.pageValues.selectedItemList??>
																<#assign checkFlag=false/>
																<#list statistic.pageValues.selectedItemList as selectedItem>
																	<#if selectedItem==item.id><#assign checkFlag=true><#assign selectedItemNames=selectedItemNames+','+item.name></#if>
																</#list>
																<#if checkFlag>checked</#if>
															</#if>>${item.name}</input></label>
															<br>
															<#assign a=a+1> 
															<#if a%3==0>
															</#if>
														</#list>
													</div>
													<div class="buttonBox" style="position:absolute;bottom:0px;background:#f3f4f4;height:30px;padding-top:4px">
														<a href="javascript:void(0);" class="button" tabindex="-1"><input type="button" onclick="confirmCheckbox();" value="确定"></a>
														<a href="javascript:void(0);" class="button" tabindex="-1"><input type="button" onclick="clearCheckbox();" value="清空"></a>
													</div>
												</div>
												</td>
											</#if>
												<td class="textColor" style="padding-left:15px;">维度显示一列：</td>
												<td class="elementColor">
												<select class="statisticElementColor" name="statistic.pageValues.isInOneColumn" id="isInOneColumn" onChange="checkIsInOneColumn();">
													<option value="0" <#if statistic.pageValues?? && statistic.pageValues.isInOneColumn?? && statistic.pageValues.isInOneColumn=='0'>selected</#if>>否</option>
													<option value="1" <#if statistic.pageValues?? && statistic.pageValues.isInOneColumn?? && statistic.pageValues.isInOneColumn=='1'>selected</#if>>是</option>
												</select>
												</td>
												
												
											</tr>
			                    		</table>
			                    		</div>
	                        	</div>
	                        	
	                        	<#if showButton && !isShowedButton>
	                        		<#assign isShowedButton=true>
	                        		<div style="position:relative;float:right;top:0px;right:15px">
										<table cellspacing="0" cellpadding="0">
										 	<tr>				
												<td>
		                        					<div class="searchButtonBox">
			                        					<a href="#" class="button" tabindex="-1">
			                        						<div style="position:relative;float:right;border-left:1px solid #96d0d2;border-right:1px solid #96d0d2;">
			                        							<img id="commonSearch_img" src="./../theme/default/images/main/search/normal.png" style="position:absolute;top:6px">
			                        							<input id="search" type="button" value="统计" style="margin-top:0px" onClick="">
			                        						</div>
			                        					</a>
		                        					</div>
		                        				</td>
											</tr>
										</table>
									</div>
	                        	</#if>
                        </div>
					    </#if>
                        <#if statistic.statisticType?? && statistic.statisticType=='5'>
                        <#assign menuDivNumber=menuDivNumber+1>
                        <#if (menuDivNumber == 1 || menuDivNumber == 2) && statistic_list??>
                        	<div id="queryForm2" style="background-image:url(/PNPMS/theme/default/images/main/seach_area_bg.png);float:left;width:100%;height:32px;border:1px solid #96d0d2">   
                        <#elseif !statistic_list?? && menuDivNumber == 2>
                        	<div id="queryForm2" style="background-image:url(/PNPMS/theme/default/images/main/seach_area_bg.png);float:left;width:100%;height:32px;border:1px solid #96d0d2;border-top:0px"> 
                        <#elseif !statistic_list?? && menuDivNumber == 1>
                        	<div id="queryForm2" style="background-image:url(/PNPMS/theme/default/images/main/seach_area_bg.png);float:left;width:100%;height:32px;border:1px solid #96d0d2">
                        <#else>
                        	<div id="queryForm2" style="background-image:url(/PNPMS/theme/default/images/main/seach_area_bg.png);float:left;width:100%;height:32px;border:1px solid #96d0d2;border-top:0px"> 
                        </#if>    
                        	<div style="position:relative;float:left;" >
		                        		<div style="position:relative;float:left;">
		                        		<table cellspacing="0" cellpadding="0" style="line-height:33px;*line-height:32px;">
		                        			<tr>
		                        			<td class="textColor" style="padding-left:15px;">计划时间：</td>
		                        			<td class="elementColor" ><input type="text" name="statistic.pageValues.planStartDate" value="${statistic.pageValues.planStartDate?default('2012-01-01')}"  class="Wdate time_box" onfocus="WdatePicker();"/></td>
		                        			<td class="textColor" style="padding-left:10px;">--&nbsp;&nbsp;</td>
		                        			<td class="elementColor"><input type="text" name="statistic.pageValues.planEndDate" value="${statistic.pageValues.planEndDate?default('2012-01-01')}"  class="Wdate time_box" onfocus="WdatePicker();"/></td>
		                        			<td class="textColor" style="padding-left:15px;">实际时间：</td>
		                        			<td class="elementColor"><input type="text" name="statistic.pageValues.actualStartDate" value="${statistic.pageValues.actualStartDate?default('2012-01-01')}"  class="Wdate time_box" onfocus="WdatePicker();"/></td>
		                        			<td class="textColor" style="padding-left:10px;">--&nbsp;&nbsp;</td>
		                        			<td class="elementColor"><input type="text" name="statistic.pageValues.actualEndDate" value="${statistic.pageValues.actualEndDate?default('2012-01-01')}"  class="Wdate time_box" onfocus="WdatePicker();"/></td>
		                        			
											<td class="textColor" style="padding-left:15px;">节点：</td>
											<td>
												<input type="text" readonly="readonly" id="statisticNodes" name="statisticNodes" class="textTest" value="请选择关键节点" />
												<div id="statisticNodeTab" style="position:absolute;top:0px;padding:0px;border:0px;overflow:hidden;display:none">
													<div class="main_center_center_content_center ui-tabs ui-widget ui-widget-content" style="position:absolute;top:0px;padding:0px;border:0px;overflow:hidden">
														<ul class="ui-tabs-nav ui-widget-header" style="-moz-border-radius-bottomleft: 0; -moz-border-radius-bottomright: 0;height:25px">
															<#list statistic_node_list?keys as volClass>
															<li id="id${volClass?replace(".","")}" class="ui-state-default ui-corner-top" style='display:inline;cursor:pointer;font-size:12px;font-weight: bold; color: #122664;border-bottom:0'>
																<div class="leftBorder" style="font-size: 1px;position:relative;background-image:url('./../theme/default/images/main/tab_left.png');float:left;left:0px;width:3px;height:26px"></div>
																<div class="contentInner"  style="padding: 0px;line-height:14px;height:25px;position:relative;float:left;border-top:1px solid #c2e2eb;background-image:url('./../theme/default/images/main/tabs.png');">
																	<a><span style="cursor:pointer;color:#122664" >${volClass}</span></a>
																</div>
																<div class="rightBorder" style="font-size: 1px;position:relative;background-image:url('./../theme/default/images/main/tab_right.png');float:left;right:0px;width:3px;height:26px">&nbsp;&nbsp;&nbsp;</div>
															</li>
															</#list>
														</ul>
														<div id="tab_content" style="height:100%;position:relative;;background-color:#edfbfe">
															<div id="tab_content_div" style="height:100%;position:absolute;overflow-y:auto;overflow-x:hidden;width:100%">
																<#list statistic_node_list?keys as volClass>
																<div id="tab_id${volClass?replace(".","")}" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" style="padding:0px;">
																	 <div class="ui-tabs-panel-forcalc">
																	 <#list statistic_node_list[volClass]?keys as phaseName>
																	 	<span>${phaseName}</span><br>
																	 	<table>
																	 		<#list statistic_node_list[volClass][phaseName] as node>
																	 			<#if node_index%2==0>
																		 		<tr>
																		 		</#if>
																	 			<td style="width:140px">
																	 			<label style="color:#122664;cursor:pointer;" for="${node.id}">
																	 			<input type="checkbox" AutoPostBack="true" onclick="selectedItem(this)" name="statistic.pageValues.selectedNodeList" value="${node.id}" id="${node.id}" itemname="${node.node.nodeName}"
																				<#if statistic.pageValues?? && statistic.pageValues.selectedNodeList??>
																					<#assign checkFlag=false/>
																					<#list statistic.pageValues.selectedNodeList as selectedNode>
																						<#if selectedNode==node.id><#assign checkFlag=true><#assign selectedNodes=selectedNodes+','+node.node.nodeName></#if>
																					</#list>
																					<#if checkFlag>checked</#if>
																				</#if>>${node.node.nodeName}</input></label>
																				</td>
																	 			<#if node_index%2==1>
																		 		</tr>
																		 		</#if>
																		 		<#if node_index%2==0 && !node_has_next><td></td></tr>
																		 		</#if>
																			</#list>
																		</table>	
																		<br>	
																	</#list>
																	</div>
																</div>
																</#list>
															</div>
														</div>
														<div class="buttonBox" style="position:absolute;bottom:0px;background:#f3f4f4;height:30px;padding:4px 0 10px 0">
															<a href="javascript:void(0);" class="button" tabindex="-1"><input type="button" onclick="confirmCheckbox();" value="确定"></a>
															<a href="javascript:void(0);" class="button" tabindex="-1"><input type="button" onclick="clearCheckbox();" value="取消"></a>
														</div>
													</div>
													<div style="background-image: url('./../theme/default/images/main/path_progress.png');width:100%;height:36px;"></div>
												</div>
											</td>
		                        			
		                        			<tr>
		                        		</table>
		                        		</div>
		                    </div>   		
                            <#if !isShowedButton >
                               	<#assign isShowedButton=true>
                        		<div style="position:relative;float:right;top:0px;right:3px">
									<table cellspacing="0" cellpadding="0">
									 	<tr>				
											<td>
	                        					<div class="searchButtonBox">
	                        					<a href="#" class="button" tabindex="-1">
		                        					<div style="position:relative;float:right;border-left:1px solid #96d0d2;border-right:1px solid #96d0d2;">
			                        					<img id="commonSearch_img" src="./../theme/default/images/main/search/normal.png" style="position:absolute;top:6px">
			                        					<input id="search" type="button" value="统计" style="margin-top:0px" onClick="">
		                        					</div>
	                        					</a>
	                        					</div>
	                        				</td>
										</tr>
									</table>
								</div>
                        	</#if>
                        </div>
					    </#if>
                        
</div>
</div>
</#if>





</form>
<input type="hidden" id="statisticId" name="statistic.id" value="${statistic.id}">
<input type="hidden" id="functionId" name="function.id" value="${function.id}">
<input type="hidden" id="businessInstanceId" name="businessInstance.id" <#if businessInstance?? && businessInstance.id??>value="${businessInstance.id}"</#if>>

<div class="center" style="height:100%;padding:0px;">
    	<div class="center_c_n" style="background-image: url(./../theme/default/images/main/pane_top.png)"></div>
        <div class="center_c_c">
        	<div class="center_c_c_n">
        	    <div style="position:relative;float:left;clear:left:top:0px;left:5px;line-height:25px;line-height:30px\9;z-index:800">
        	    <span title="<#list statistic.comments as comment>${comment_index + 1}. ${comment.comment}
</#list>">${statistic.name}</span><#if statistic.unit??> &nbsp;单位：${statistic.unit}</#if></div>
	            <div class="toolbar">
	                <ul class="program_toolbar" id="mainButton">
	                
	                    <#list common_func_list?reverse as comFunc>
                        <#assign show="0">
                        <#list feature_list as feature>
                            <#if comFunc.function.name==feature.code>
                                <#assign show="1">
                            </#if>
                        </#list>
                        <#if show?? && show=="1">
                            <#if comFunc.function.icon??>
                            	<#if comFunc.function.url??>
                            		<li id="exportStatisticID" class="${comFunc.function.icon}" style="cursor:pointer" onclick="javascript:showUrl('${comFunc.function.url}');return false;"><a href="javascript:void(0)"><img src="./../theme/default/images/main/blank.gif" style="float:left;clear:left"><div style="line-height:20px;line-height:23px\9;float:left;cursor:pointer"><span style="cursor:pointer">${comFunc.function.displayName?default('')}</span></div></a></li>
                            	<#else>
	                            	<#if comFunc.function.isFunctionGroup?? && comFunc.function.isFunctionGroup=="1">
	                            	<li class="${comFunc.function.icon}" style="cursor:pointer" ><a href="javascript:void(0)"><img src="./../theme/default/images/main/blank.gif" style="float:left;clear:left"><div style="line-height:20px;line-height:23px\9;float:left;cursor:pointer"><span style="cursor:pointer" onmouseover="javascript:showFunctionGroup(this,'${comFunc.function.id}',event);return false;" onmouseout="javascript:closeFunctionGroup('${comFunc.function.id}',event);return false;">${comFunc.function.displayName?default('')}</span></div></a></li>
	                            	<div id="div${comFunc.function.id}" style="display:none;position:relative">
		                            	<ul style="list-style:none;line-height:20px;">
		                            	<#list common_func_list?reverse as commonFunc>
			                            	<#assign show="0">
						                        <#list feature_list as feature>
						                            <#if commonFunc.function.name==feature.code>
						                                <#assign show="1">
						                            </#if>
						                        </#list>
						                        <#if show?? && show=="1" && commonFunc.function.parentFunction?? && commonFunc.function.parentFunction.id == comFunc.function.id>
						                        	<li class="${commonFunc.function.icon}" style="cursor:pointer" onclick="javascript:processCommonFunc('${commonFunc.function.id}',<#if commonFunc.isBatch??>'${commonFunc.isBatch}'<#else>'0'</#if>,<#if commonFunc.function.messageType??>'${commonFunc.function.messageType}'<#else>'0'</#if>,<#if commonFunc.function.message??>'${commonFunc.function.message}'<#else>''</#if>,<#if commonFunc.function.forwardType??>'${commonFunc.function.forwardType}'<#else>''</#if>,<#if commonFunc.function.clearSession??>'${commonFunc.function.clearSession}'<#else>'0'</#if>,<#if commonFunc.function.isPassParams??>'${commonFunc.function.isPassParams}'<#else>'0'</#if>);return false;"><a href="javascript:void(0)"><div style="position:relative;top:5px;float:left;clear:left"><img src="./../theme/default/images/main/037.gif" style="float:left;clear:left"></div><span style="cursor:pointer">${commonFunc.function.displayName?default('')}</span></a></li>
						                        </#if>
	                            		</#list>
	                            		</ul>
	                            	</div>
	                            	<#else>
		                            	<#if  !comFunc.function.parentFunction??>
		                                <li class="${comFunc.function.icon}" style="cursor:pointer" onclick="javascript:processCommonFunc('${comFunc.function.id}',<#if comFunc.isBatch??>'${comFunc.isBatch}'<#else>'0'</#if>,<#if comFunc.function.messageType??>'${comFunc.function.messageType}'<#else>'0'</#if>,<#if comFunc.function.message??>'${comFunc.function.message}'<#else>''</#if>,<#if comFunc.function.forwardType??>'${comFunc.function.forwardType}'<#else>''</#if>,<#if comFunc.function.clearSession??>'${comFunc.function.clearSession}'<#else>'0'</#if>,<#if comFunc.function.isPassParams??>'${comFunc.function.isPassParams}'<#else>'0'</#if>);return false;"><a href="javascript:void(0)"><img src="./../theme/default/images/main/blank.gif" style="float:left;clear:left"><div style="line-height:20px;line-height:23px\9;float:left;cursor:pointer"><span style="cursor:pointer">${comFunc.function.displayName?default('')}</span></div></a></li>
		                            	</#if>
	                            	</#if>
                            	</#if>
                            <#else>
                                <li class="t8" style="cursor:pointer"><a href="javascript:void(0);"><img src="./../theme/default/images/main/blank.gif" onclick=""><br/></a></li>
                            </#if>
                     </#if>
                    </#list>
						<li id="showTableButton" style="display:none;" class="t17" style="cursor:pointer" onclick="showChart()"><a href="javascript:void(0);"><img style="float:left;clear:left" src="./../theme/default/images/main/blank.gif"><div style="line-height:20px;line-height:23px\9;float:left;cursor:pointer"><span>切换图表</span></div><br/></a></li>
		                <#if isJunitTest>
							<li class="t17" style="cursor:pointer" onclick="testButton()"><a href="javascript:void(0);"><img style="float:left;clear:left" src="./../theme/default/images/main/blank.gif"><div style="line-height:20px;line-height:23px\9;float:left;cursor:pointer">Test Button</div><br/></a></li>
		                </#if>
	                </ul>
	            </div>
	       	</div>   
	       	<div class="center_c_c_c">  
	       		<!--jquery validator显示错误信息的容器 -->
		        <div class="serverErrorContainer" style="position:relative;">
			        <div class="serverError">
			        <ol>

			        </ol>
			        </div>
		    
			        <div class="container">
			            <div class="searchButtonBox handleDiv" onclick="displayTable('handleDiv')">
			            	<a href='javascript:void(0);' class="button switchOpen"  tabindex="-1" >
			    			<div style="border:1px solid #96d0d2;border-bottom:0px;position:relative;float:right;cursor:pointer;">
			    			<img id="handleDiv" src="./../theme/default/images/main/search/search_switch_open_normal.png" style="position:absolute;top:6px">
			    			<input type="button" style="margin-top:0px;width:16px;">
			    			</div>
			    			</a>
			            </div>
			            <div id="handleDiv_child" class="errorDIv" divAttend="attend">
			                <ol>
			                </ol>
			            </div>
			        </div>
		   	 	</div>
		   	 	<!-- end -->
            	
            	<!-- 将统计结果展示为table形式-->
            	<!-- 
            	循环出table
            	1.需要后台先计算出总体循环次数
            	2.一次一个tr
            	3.tr内部的td根据统计分类循环
            	4.
            	-->
				<div id="tableDiv">
	            	<table id="statisticGridTable"></table>
            	</div>

				<div id="chartDiv" style="display:none;">				    
					<div id="container" style="width: 800px; height: 500px; margin: 0 auto;overflow:hidden"></div>
				</div>
        	</div>
        	<div class="center_c_c_s">
			    <div class="content_s">
			    	<#if function_list?? && function_list?size gt 0>
				        <div class="buttonBox">
					        <#list function_list as func>
					            <a href="#" class="button" tabindex="-1">
					            <#t><input id="btn${func.function.name}" type="button"  class="button" value="<#if func.function?? && func.function.displayName??>${func.function.displayName}</#if>" onclick="processButton('${func.function.id}','<#if func.function?? && func.function.type??>${func.function.type}</#if>',<#if func.function.messageType??>'${func.function.messageType}'<#else>'0'</#if>,<#if func.function.message??>'${func.function.message}'<#else>''</#if>,<#if func.function.clearSession??>'${func.function.clearSession}'<#else>'0'</#if>,<#if func.function.logicConfirmMessage??>'${func.function.logicConfirmMessage}'<#else>''</#if>,<#if func.function.logicBranchFunction??>'${func.function.logicBranchFunction.id}'<#else>''</#if>)"/>&nbsp;&nbsp;
					            </a>
					        </#list>
				        </div>
			        </#if>
			    </div>
        	</div>
        </div><!--center_c_c-->
    
    
   
</div><!--center-->


<form id="argsForm" action="/business/process?tdqssid=<%=session.getId()%>" onSubmit="return false">
    <!-- 统计功能扩展开始-->
    <#if statistic_args_from_list??>
		<#list statistic_args_from_list?keys as key>
			<#if statistic_args_from_list[key]??>
		    <#if statistic_args_from_list[key].formatter??>
                <input type="hidden"  name="argsMap['${key}'].formatter" value='${"${"}statistic_args_from_list["${key}"].formatter${"?default(\"\")}"}' />
            </#if>
			<input type="hidden" name="argsMap['${key}'].filterValue" value='${"${"}statistic_args_from_list["${key}"].filterValue${"?default(\"\")}"}' id="${key}" />
			<input type="hidden"  name="argsMap['${key}'].filterName" value='${"${"}statistic_args_from_list["${key}"].filterName${"?default(\"\")}"}' />
			<input type="hidden"  name="argsMap['${key}'].expType" value='${"${"}statistic_args_from_list["${key}"].expType${"?default(\"\")}"}' />
			<input type="hidden"  name="argsMap['${key}'].fieldId" value='${"${"}statistic_args_from_list["${key}"].fieldId${"?default(\"\")}"}' />
			</#if>
		</#list>
	</#if>
    <!-- 统计功能扩展结束 -->
</form>
<form id="hiddenForm">
<#if paramsMap??>
    <#list paramsMap?keys as key>
        	<#if paramsMap[key].field??>
            <input type="hidden" name="paramsMap['${key}'].field.id" <#if paramsMap[key].field.id??> value="${paramsMap[key].field.id}"</#if>>
            </#if>
            <input type="hidden" name="paramsMap['${key}'].value" <#if paramsMap[key].value??> value="${paramsMap[key].value}"</#if>></input>
            <input type="hidden" name="paramsMap['${key}'].entityId" <#if paramsMap[key].entityId??> value="${paramsMap[key].entityId}"</#if>></input>
    </#list>
</#if>
</form>


<script language="javascript">
//统计分类选项集合
var tabsVolArray = [<#if !statistic.isTree?? || statistic.isTree == "0"><#if statistic_list??><#list statistic_list as item>"${item.id}"<#if item_has_next>,<#else></#if></#list></#if></#if>];
var tabsNodeArray = [<#if !statistic.isTree?? || statistic.isTree == "0"><#if statistic_node_list??><#list statistic_node_list?keys as volClass>"id${volClass?replace(".","")}"<#if volClass_has_next>,<#else></#if></#list></#if></#if>];
var chart;
var chartData;
var scrollBarWidth=0;
var tabdivFixHeight=20;
var dimesionOptions= new Array();
<#if dimension_list??>
	<#list dimension_list as dimesion>
	dimesionOptions.push({
		key:"${dimesion.id}",value:"<option value='${dimesion.id}'>${dimesion.name}</option>"
    });
    </#list>
</#if>						

function getDimesionOption(_key) {
    try {
        for (i = 0; i < dimesionOptions.length; i++) {
            if (dimesionOptions[i].key == _key) {return dimesionOptions[i].value;}
        }
    } catch (e) {
        return null;
    }
}

function listChart(condition){
	var encodeCondition = encodeURI(condition);
	
	var url = TDQS.CONTEXT_PATH+'business/childchart.action?tdqssid='+TDQS.SESSION_ID+ "&businessProcess.id="+${"$('#businessProcessId')"}.val() + "&" + encodeCondition +"&statistic.id="+ "${statistic.id}" + "&fromPageId="+"${statistic.id}";

    //postForm(url,true);
    $.tdqsAjax({
        type: "post",
        dataType: "json",
        data: $('#searchForm').serialize(),
        url: url,
        success:function(json) {
            if(json.data){
	            chartData = eval('('+json.data+')');
	            <#if (statistic.isShowAutoChart?? && statistic.isShowAutoChart=='1')||(statistic.chartType?? && statistic_data_chart??)||(statistic.statisticType?? && statistic.statisticType=='2')>
					$("#chartDiv #container").css("height",window.document.body.clientHeight-$(".serverErrorContainer").height()-40-30-2-${menuDivNumber*34});
					if($.browser.msie&&($.browser.version == "6.0")){
						$("#chartDiv #container").css("width",window.document.body.clientWidth-scrollBarWidth);
					}
				</#if> 
				chart = new Highcharts.Chart(chartData);
			    $("#chartDiv").toggle();
				$("#tableDiv").toggle();
				$("#showTableButton").show();
            }
        }
    });
}

function showChart(){
	//alert("showChart");
	$("#chartDiv").toggle();
	$("#tableDiv").toggle();
	$("#viewTable").toggle();
	$("#viewChart").toggle();
	
}

function disabledAllButton() {
    //$('.button').attr('disabled','disabled');
}

<#if isJunitTest>
	function testButton(){
		alert($(".ui-tabs-nav #tab_id10kV"))
		alert("clientHeight:"+window.document.body.clientHeight + "||clientWidth:" +window.document.body.clientWidth );
	}
	function JsonToString(o) {    
		var arr = []; 
		var fmt = function(s) { 
			if (typeof s == 'object' && s != null) return JsonToString(s); 
			return /^(string|number)$/.test(typeof s) ? "'" + s + "'" : s; 
		} 
		 
		if('[object Array]' == Object.prototype.toString.call(o)){
			for (var i in o) 
				arr.push(fmt(o[i])); 
			return '[' + arr.join(',') + ']'; 
		}else{
			for (var i in o) 
				arr.push("'" + i + "':" + fmt(o[i])); 
			return '{' + arr.join(',') + '}'; 
		}
	} 
</#if>
<#if (!statistic.syncFlag?? || statistic.syncFlag!="1") && statistic_data_title_list?? && statistic_data_title_list?size gt 0>
	function showGrid(){
		$('#statisticGridTable').datagrid({
			//url: 'datagrid_data2.json',
			//title: '${statistic.name}',
			//width: 700,
			pagination:false,
			autoRowHeight:true,
			//showHeader:false,
			//height: 'auto',
			//fitColumns: true, ${statistic.dimensionList?size}
			<#assign froneSize=0>
			<#assign addFroneSize=false>
			<#if statistic.statisticType?? && statistic.statisticType=='2'>
				<#if  (statistic.pageValues?? && statistic.pageValues.secondDimesionId?? && statistic.pageValues.secondDimesionId!='' && statistic.pageValues.layoutType?? && statistic.pageValues.layoutType=='2')|| (statistic.pageValues?? && statistic.pageValues.thirdDimesionId?? && statistic.pageValues.thirdDimesionId!='')>
					<#assign addFroneSize=true>
				</#if>
			<#else>
				<#if (statistic.dimensionList?? && statistic.dimensionList?size == 3) || (statistic.dimensionList?? && statistic.dimensionList?size == 2 && statistic.dimensionList[1].direction=='x')>
					<#assign addFroneSize=true>
				</#if>
			</#if>
				frozenColumns:[[		
							<#if (statistic.statisticType?? && statistic.statisticType=='2' && statistic.pageValues?? && statistic.pageValues.firstDimesionId?? )
								||( (!statistic.statisticType?? || (statistic.statisticType?? && statistic.statisticType!='2'))&& statistic.dimensionList?? && statistic.dimensionList?size gt 0)>
								<#assign tempCell=statistic_data_title_list[0][0]>			
								{<#rt>
								<#t><#if tempCell.colSpan==1>field:'data0',<#else>field:'data',</#if>
								<#t>title:'${tempCell.cellName}',
								<#t>width:'${tempCell.width}',
								<#t><#if tempCell.align??>align:'${tempCell.align}',</#if>
								<#t>rowspan:${tempCell.rowSpan},
								<#t>colspan:${tempCell.colSpan}
								<#t>,editor : 'text',defaultValue : '',edit : true
								<#lt>}
								<#assign froneSize=1>
							</#if>
							<#if (statistic.statisticType?? && statistic.statisticType=='2' &&  statistic.pageValues?? && statistic.pageValues.secondDimesionId?? && statistic.pageValues.secondDimesionId!='' && statistic.pageValues.layoutType?? && statistic.pageValues.layoutType=='1')
								||(statistic.statisticType?? && statistic.statisticType!='2' && statistic.dimensionList?? && statistic.dimensionList?size gt 1 && statistic.dimensionList[1].direction=='y')>
								<#assign tempCell2=statistic_data_title_list[0][1]>			
								,{<#rt>
								<#t><#if tempCell2.colSpan==1>field:'data1',<#else>field:'data',</#if>
								<#t>title:'${tempCell2.cellName}',
								<#t>width:'${tempCell2.width}',
								<#t><#if tempCell2.align??>align:'${tempCell2.align}',</#if>
								<#t>rowspan:${tempCell2.rowSpan},
								<#t>colspan:${tempCell2.colSpan}
								<#t>,editor : 'text',defaultValue : '',edit : true
								<#lt>}
								<#assign froneSize=2>
							</#if>
						
				]],
			columns:[
				<#list statistic_data_title_list as title>
					<#assign needComma=false>
					[<#list title as cell>
					    <#if (title_index > 0) || (cell_index > froneSize-1)>
					    	<#if cell.fillType=='real'>
					    		<#rt><#if needComma>,</#if>
								<#t>{
								<#t><#if cell.cellValueType=="3">field:'data${cell_index}',<#else>field:'',</#if>
								<#t>title:'<#if cell.link??><a href="javascript:void(0)" <#if cell.tip??>title="${cell.tip}"</#if>onclick="listChart(\'${cell.link?replace("'","\\\\\\'")}\')">${cell.cellName}</a><#else><span<#if cell.tip??> title="${cell.tip}"</#if>>${cell.cellName}</span></#if>',
								<#t>width:'${cell.width}',
								<#t><#if cell.align??>align:'${cell.align}',</#if>
								<#t>rowspan:${cell.rowSpan},
								<#t>colspan:${cell.colSpan}
								<#t>,editor : 'text',defaultValue : '',edit : true
								<#t>}
								<#assign needComma=true>
							</#if>
						</#if>
					</#list>
					]
					<#if title_has_next>,</#if>
				</#list>
			],
			onLoadSuccess:function(data){
				if($('#statisticGridTable').datagrid('getData').total ==0){
					$('#statisticGridTable').datagrid('emptyDataHandle');
				}
			}
		});
		
		<#if statistic_data_body_list?? && statistic_data_body_list?size gt 0>
			var dataJson = {"total":${statistic_data_body_list?size},'rows':[
			<#list statistic_data_body_list as body>
				<#t>{<#list body as cell>
					<#t>"data${cell_index}":"<#if cell.link??><a href=\"javascript:void(0)\" onclick=\"listDetail('${cell.link?replace("'","\\\\'")}');return false;\"><#if cell.cellName??>${cell.cellName}<#else>0</#if></a><#else><#if cell.cellName??>${cell.cellName}<#else>0</#if></#if>"
					<#t><#if cell_has_next>,</#if>
				</#list>
				<#lt>}
				<#t><#if body_has_next>,</#if>
			</#list>
			]};
			$('#statisticGridTable').datagrid('loadData',dataJson);
			mergeCell();
			resizeDataGrid=true;
			//contentLayout();
			//resizeDatagrid();
		<#else>
			var dataJson = {"total":0,'rows':[{"data":""}]};
			$('#statisticGridTable').datagrid('loadData',dataJson);
			resizeDataGrid=true;
		</#if>
		if(resizeDatagrid){resizeDatagrid();}
	}
	function mergeCell(){
		<#if statistic_data_body_list??>
			<#list statistic_data_body_list as body>
				<#list body as cell>
					<#if cell.rowSpan gt 1 || cell.colSpan gt 1>
						$('#statisticGridTable').datagrid('mergeCells',
							{index:${body_index},field:"data${cell_index}",rowspan:${cell.rowSpan},colspan:${cell.colSpan}});
					
					</#if>
				</#list>
			</#list>
		</#if>
	}
</#if>

$(function(){
	parent.parent.addVisitPath('${statistic.name}');
	$("#search_area").css('top',$("#outer_tabs").height());
	$("#selectAllItemID").click(function(){
		var value = '';
		if($(this).attr("checked")){
			$('input[name="statistic.pageValues.selectedItemList"]',document.getElementById('DropdownMenu')).each(function(){
				$(this).attr("checked",true);
				value += ($(this).attr("itemname")+',');
		    });
			if(value!='') {
				value = value.substring(0,value.length-1);
			}
		}else{
			$('input[name="statistic.pageValues.selectedItemList"]',document.getElementById('DropdownMenu')).each(function(){
				$(this).removeAttr("checked");
		    });
		}
	    document.getElementById('statisticObj').value = value;
	});
	
	$('input[name="statistic.pageValues.selectedItemList"]',document.getElementById('DropdownMenu')).click(function(){
		var value = '';
		$('input[name="statistic.pageValues.selectedItemList"]',document.getElementById('DropdownMenu')).each(function(){
			if($(this).attr("checked")){
				value += ($(this).attr("itemname")+',');
			}
		});
		if(value!='') {
			value = value.substring(0,value.length-1);
		}
		document.getElementById('statisticObj').value = value;
	});
	<#if selectedItemNames?? && selectedItemNames!=''>
		var value = '${selectedItemNames}';
		value = value.substring(1,value.length);
		document.getElementById('statisticObj').value = value;
	</#if>
	<#if statistic.syncFlag?? && statistic.syncFlag=="1">
		$('#exportStatisticID').hide();
		loadTable('${function.id}');
	<#else>
		<#if statistic_data_title_list??>
			showGrid();
		<#else>
			$('#exportStatisticID').hide();
		</#if>
	</#if>
	
	if(tabsNodeArray && tabsNodeArray[0]){
		shortCutMenuPosition(tabsNodeArray);
		$("#"+tabsNodeArray[0]).click();
	}
	<#if statistic.chartType?? && statistic_data_chart??>
		$("#showTableButton").show();
	</#if>
});

<#if statistic.syncFlag?? && statistic.syncFlag=="1">
	function loadTable(functionId){
		$('#exportStatisticID').hide();
		$("#showTableButton").hide();
		var url = TDQS.CONTEXT_PATH+'business/loadtable.action?tdqssid='+TDQS.SESSION_ID+ "&function.id="+functionId + "&businessProcess.id="+${"$('#businessProcessId')"}.val() +"&statistic.id="+ "${statistic.id}" + "&fromPageId="+"${statistic.id}";
   		url += "&clearSession=true"; 
   		block($('body'),"数据加载中，请稍候...");
	    $.tdqsAjax({
	        type: "post",
	        dataType: "json",
	        data: $('#searchForm').serialize() + '&' + $('#hiddenForm').serialize(),
	        url: url,
	        success:function(json) {
	            if(json.data){
	            	var result = eval("("+json.data+")");
	            	if(result.errorMessage){
		           		//$('#exportStatisticID').show();
		           		unblock($('body'));
		           		$("#chartDiv").hide();
						$("#tableDiv").hide();
	            		jAlert(result.errorMessage,'提示',function(){});
	            		resizeDataGrid=false;
	            	}else{
	            		$('#tableDiv').show();
	            		$("#chartDiv").hide();
		            	//alert(result.tableData.columns[0][0].title);
		            	$('#statisticGridTable').datagrid(result.tableData);
		            	$('#statisticGridTable').datagrid({			
		            		onLoadSuccess:function(data){
								if($('#statisticGridTable').datagrid('getData').total ==0){
									$('#statisticGridTable').datagrid('emptyDataHandle');
								}
							}
						});
		            	$('#statisticGridTable').datagrid('loadData',result.jsonData);
		            	//merge cell
		           		var mergeData = result.mergeData;
		           		for(var i=0;i<mergeData.length;i++){
		           			$('#statisticGridTable').datagrid('mergeCells',mergeData[i]);
		           		}
		           		$('#exportStatisticID').show();
		           		if(result.chartData){
		           			$("#showTableButton").show();
		           			var chartResult=eval("("+result.chartData+")");
		           			chart = new Highcharts.Chart(chartResult);
		           		}
		           		//contentLayout();
		           		//resizeDatagrid();
		           		resizeDataGrid=true;
		           		unblock($('body'));
	            	}
	            }
	        }
	    });
	    if(resizeDatagrid){resizeDatagrid();}
	}
</#if>
<!--123123 -->
var firstSelect="";
var secondSelect="";

jQuery(function(){
	<#if statistic.pageValues?? && statistic.pageValues.firstDimesionId??>
		firstSelect='${statistic.pageValues.firstDimesionId}';
		jQuery("#secondWeb").removeAttr("disabled");
		jQuery("#secondLayout").removeAttr("disabled");
		jQuery("#secondWeb option[value='"+firstSelect+"']").remove();
		jQuery("#thirdWeb option[value='"+firstSelect+"']").remove();
	<#else>
		jQuery("#secondWeb").attr("disabled","true");
		jQuery("#secondLayout").attr("disabled","true");
	</#if>
	
	<#if statistic.pageValues?? && statistic.pageValues.secondDimesionId?? && statistic.pageValues.secondDimesionId!=''>
		secondSelect='${statistic.pageValues.secondDimesionId}';
		jQuery("#thirdWeb option[value='"+secondSelect+"']").remove();
	<#else>
		jQuery("#thirdWeb").attr("disabled","true");
	</#if>
	<#if statistic.pageValues?? && statistic.pageValues.thirdDimesionId??>
	</#if>
	
});
addLoadEvent(statisticElement);

function selectedItem(obj){
	if($.browser.msie&&($.browser.version == "6.0" || $.browser.version == "7.0")){
	}else{
		if($(obj).attr("checked")){
			$(obj).removeAttr("checked");
		}else{
			$(obj).attr("checked",true);
		}
	}
}

function itemChanged(obj){
	if(obj){
		selectedItem(obj)
	}
	var selectAll=true;
	$('input[name="statistic.pageValues.selectedItemList"]',document.getElementById('DropdownMenu')).each(function(){
		if(!$(this).attr("checked")){
			selectAll=false;
		}
	});
	if(selectAll){
		$("#selectAllItemID").attr("checked",true);
	}else{
		$("#selectAllItemID").removeAttr("checked");
	}
}

function statisticElement(){
	$('input[type="text"]:not(".textTest")','#queryForm').width(90);
	$('select:not(".keepsize")','#queryForm').width(120);
	$('#statisticItems').width(200);
	$(document.getElementById('statisticObj')).inputStyle({
		operatorType:"text",
		operatorText:"选择",
		controllerWidth:'120',
		operatorFun:showMenu_statistic
	});
	$(document.getElementById('statisticNodes')).inputStyle({
		operatorType:"text",
		operatorText:"选择",
		controllerWidth:'120',
		operatorFun:showMenu_statisticNode
	});
}

function showMenu_statisticNode()
{
	new DDWin({
		el:"statisticNodeTab"
		,dep:'divAround_statisticNodes'
		,clickBody:'save'
		<#if statistic_node_list??>
		//${statistic_node_list?size}
		//${statistic_node_list?keys?size}
		,width: 300
		</#if>
	});
}

function showMenu_statistic()
{
	new DDWin({
		el:"DropdownMenu"
		,dep:'divAround_statisticObj'
		,clickBody:'save'
	});
}

//clean value
function clearCheckbox(){
	$("input:checkbox","#DropdownMenu").removeAttr("checked");
	$("#statisticObj").val("");
	window.curDDWin.saveWin();
}
function confirmCheckbox(){
	window.curDDWin.saveWin();
}
function checkIsInOneColumn(){
	var columnValue = $('#isInOneColumn').val();
	if(columnValue == '1'){
		jQuery("#secondLayout").attr("disabled","true");
	}else{
		if(firstSelect!=""){
			jQuery("#secondLayout").removeAttr("disabled");
		}
	}
}
function firstWebfun(){
    if(firstSelect!=""){
    	//alert(getDimesionOption(firstSelect));
    	$(getDimesionOption(firstSelect)).appendTo(jQuery("#secondWeb"));
    	$(getDimesionOption(firstSelect)).appendTo(jQuery("#thirdWeb"));
        //jQuery("#secondWeb option[value='"+firstSelect+"']").removeAttr("disabled");
        //jQuery("#thirdWeb option[value='"+firstSelect+"']").removeAttr("disabled");
    }
	firstSelect=jQuery("#firstWeb option:selected").attr("value");
    if(firstSelect==""){
    	
    	jQuery("#secondWeb option:selected").removeAttr("selected");
    	jQuery("#secondWeb option[value='']").attr("selected","selected");
    	$(getDimesionOption(secondSelect)).appendTo(jQuery("#thirdWeb"));
		secondSelect="";
		jQuery("#secondWeb").attr("disabled","true");
		jQuery("#secondLayout").attr("disabled","true");

		jQuery("#thirdWeb").attr("disabled","true");
		jQuery("#thirdWeb option[value='']").attr("selected","selected");
    }else{
		jQuery("#secondWeb").removeAttr("disabled");
		jQuery("#secondLayout").removeAttr("disabled");
		jQuery("#secondWeb option[value='"+firstSelect+"']").remove();
    	jQuery("#secondWeb option:selected").removeAttr("selected");
    	jQuery("#secondWeb option[value='']").attr("selected","selected");
    	$(getDimesionOption(secondSelect)).appendTo(jQuery("#thirdWeb"));
		secondSelect="";

		jQuery("#thirdWeb").attr("disabled","true");
		jQuery("#thirdWeb option[value='"+firstSelect+"']").remove();
		jQuery("#thirdWeb option[value='']").attr("selected","selected");
	}

}
function secondWebfun(){
    if(secondSelect!=""){
    	$(getDimesionOption(secondSelect)).appendTo(jQuery("#thirdWeb"));
        //jQuery("#thirdWeb option[value='"+secondSelect+"']").removeAttr("disabled");
    }
	secondSelect=jQuery("#secondWeb option:selected").attr("value");
   	if(secondSelect==""){
		jQuery("#thirdWeb option[value='']").attr("selected","selected");
		jQuery("#thirdWeb").attr("disabled","true");
   	}else{
		jQuery("#thirdWeb").removeAttr("disabled");
	    jQuery("#thirdWeb option[value='"+secondSelect+"']").remove();
		jQuery("#thirdWeb option[value='']").attr("selected","selected");
	}
}


//其他统计
function clickStatistic(obj){
	var statisticId = $("#"+obj).attr("itemid");
	var functionId = $("#"+obj).attr("itemfunid");
	//后台处理传参
	var url = TDQS.CONTEXT_PATH+'business/process?tdqssid='+TDQS.SESSION_ID+ "&function.id="+functionId+"&businessProcess.id="+${"$('#businessProcessId')"}.val()+"&statistic.id="+statisticId;
    //不使用历史session
    url += "&clearSession=true";   
    //alert('url is : ' + url);
    document.location.href = url;
}
//统计链接，需要传参表单和查询表单
function listDetail(condition){
	//alert(condition);
   	
   	//condition += "&clearSession=true";
	var encodeCondition = encodeURI(condition);
	//var encodeCondition = condition;
	
	var searchFormConditon = $('#searchForm').serialize();
	//alert("searchFormConditon::" + searchFormConditon);
	if(searchFormConditon !="" && searchFormConditon.indexOf('%2C')>-1) {
		var re = /%2C/g;
		searchFormConditon = searchFormConditon.replace(re,',');
	}
	//alert("searchFormConditon::" + searchFormConditon);
	var url = TDQS.CONTEXT_PATH+'business/process.action?tdqssid='+TDQS.SESSION_ID+ "&businessProcess.id="+${"$('#businessProcessId')"}.val() + "&"+ searchFormConditon + "&" + encodeCondition +"&statistic.id="+ "${statistic.id}" + "&fromPageId="+"${statistic.id}";
	//传参处理
	var args = $('#argsForm').serialize();
	if(args !=''){
		url = url + "&" + args;
	}
	<#if statistic.isPassParams?? && statistic.isPassParams=="1">
	var hiddenFrom = $('#hiddenForm').serialize();
	if(hiddenFrom != ''){
      	url = url+'&'+$('#hiddenForm').serialize();
    }
    </#if>

    if(url !="" ){
		var reFilter = /filterMap/g;
		url=url.replace(reFilter,'argsMap');
	}
    postForm(url,true);
}

$(function(){
	//$("#chartDiv").hide();
	$("#viewTable").hide();
    layout();
    //loadGrid();
	<#if (statistic.isShowAutoChart?? && statistic.isShowAutoChart=='1')||(statistic.chartType?? && statistic_data_chart??)||(statistic.statisticType?? && statistic.statisticType=='2')>
		$("#chartDiv #container").css("height",window.document.body.clientHeight-$(".serverErrorContainer").height()-40-30-2-${menuDivNumber*34});
		if($.browser.msie&&($.browser.version == "6.0")){
			$("#chartDiv #container").css("width",window.document.body.clientWidth-scrollBarWidth);
		}
	</#if>    
    <#if statistic.chartType?? && statistic_data_chart??>
		chart = new Highcharts.Chart(${statistic_data_chart});
    </#if>
    $("#all_search").inputStyle({
        operatorId:"all_search_Opt",
        operatorType:"img",
        operatorImg:"./../theme/default/images/main/search.png",
        controllerWidth:200,
        operatorFun:showMenu
    });
    
    //查询
    $('#search').click(function(){
    	<#if statistic.statisticType?? && statistic.statisticType=='2'>
	    	var checkedBox = $("input[name^='statistic.pageValues.selectedItemList']:checked");
	    	//alert(checkedBox);
	    	var actor_config = "";              //定义变量
			checkedBox.each(function(i){        //循环拼装被选中项的值
			  actor_config = actor_config+','+$(this).val();
			});
			//alert(actor_config);
			if(actor_config==""){
				jAlert('请选择统计项！','提示',function(){});
				return false;
			}
			if(firstSelect==""){
				jAlert('请选择统计维度！','提示',function(){});
				return false;
			}
  		</#if>
  		<#if statistic.statisticType?? && statistic.statisticType=='5'>
	    	var checkedBoxNode = $("input[name^='statistic.pageValues.selectedNodeList']:checked");
	    	var actor_config_node = "";              //定义变量
			checkedBoxNode.each(function(i){        //循环拼装被选中项的值
			  actor_config_node = actor_config_node+','+$(this).val();
			});
			if(actor_config_node==""){
				jAlert('请选择统计节点！','提示',function(){});
				return false;
			}
  		</#if>
    	//alert("start to click search button");
        var url = TDQS.CONTEXT_PATH+'business/process?tdqssid='+TDQS.SESSION_ID + "&function.id="+'<#if statistic.fromFunction??>${statistic.fromFunction.id}<#else> </#if>' +"&statistic.id="+'${statistic.id}' + "&" + $('#searchForm').serialize();
        //不使用历史session
        url += "&clearSession=true";
    	//传参处理
    	var args = $('#argsForm').serialize();
    	if(args !=''){
    		url = url + "&" + args;
    	}
    	<#if statistic.syncFlag?? && statistic.syncFlag=="1">
    	loadTable('${statistic.fromFunction.id}');
    	<#else>
    	postForm(url,true);
    	</#if>
    });
    <#if !statistic_data_table_list??>
    	<#if statistic_error_message??>
    		<#if !statistic.isTree?? || statistic.isTree == "0">
    		$('#exportStatisticID').hide();
    		jAlert('${statistic_error_message}','提示',function(){});
    		resizeDataGrid=false;
	    	</#if>
    	</#if>
    </#if>
	resizeCenter();   
	itemChanged();
    document.getElementsByTagName('form')[0].onkeydown = function(e){
          var e = e || event;
          var keyNum = e.which || e.keyCode;
          if(keyNum==13){
              ${"$('#search')"}.click();
              return false;
          }
          return true;
        };
        contentLayout();
});

function postForm(url,isDecode){
	//alert('port');
    //form = $("<form></form>");
    //form.attr('action',url);
    //form.attr('method','post');
    //$('#searchForm').appendTo(form);
    //form.appendTo("body");
    //form.submit()
    
    //var url="http://a.com?a=1&b=2&c=3";
    if(isDecode){
    	url=decodeURI(url);
    }
	var b = url.split("?");
	var parameters = b[1].split("&");
	//alert(b[0]);
	var a = $("<form method=post action="+b[0]+"/>").appendTo("body");
	
	for(var i=0;i<parameters.length;i++){
		var parameterArray = parameters[i].split("=");
		if(parameterArray.length >1 && parameterArray[1].indexOf('%2C')>-1) {
			var re = /%2C/g;
			parameterArray[1] = parameterArray[1].replace(re,',');
		}
		var hideEle = $("<input type='hidden' name="+parameterArray[0]+" value='"+parameterArray[1]+"' />");
		$(hideEle).appendTo($(a));
	}
	$(a).submit();
}

function showUrl(url) {
	url = TDQS.CONTEXT_PATH+ encodeURI(url);
	if(url.indexOf('?')==-1) {
		url += '?';
	} else {
		url += '&';
	}
	url += 'date='+new Date().toLocaleString();
	document.location.href = url;
}
jQuery.fn.isChildAndSelfOf = function(b){//jquery扩展功能

return (this.closest(b).length > 0);

};
function showFunctionGroup(obj,id,e) {
	if($.browser.msie){
		cancelBubble=true;
	}else{
		e.stopPropagation();
	}
	//var toolbarWidth = $(".program_toolbar").width();
	//$(".program_toolbar").width(toolbarWidth+$('#div'+id).width());
	$(obj).addClass("overListButton");
	$('#div'+id).show();
	var popDiv = $("<div style='height:200px;width:200px;position:absolute;background-color:#FFFFFF;border:1px solid #cccccc;z-index:100;'/>");
	$('#div'+id).appendTo($(popDiv));
	$(popDiv).appendTo("body");
	var cWidth = window.innerWidth || document.documentElement.clientWidth;
	//判断是否按钮在最右侧
	var topSpacing = 0;
	if($.browser.msie && parseInt($.browser.version) <= 7 ){
		topSpacing = 5;
	}
	if(cWidth - ($(obj).offset().left + $(obj).width()) < 10){
		$(popDiv).css({right:0 + "px", top:$(obj).offset().top+$(obj).height()-topSpacing + "px"}).slideDown("fast");
	}else{
		$(popDiv).css({left:$(obj).offset().left-14 + "px", top:$(obj).offset().top+$(obj).height()-topSpacing + "px"}).slideDown("fast");
	}
	
	$(popDiv).attr("id","listButton_popDiv");
	$(popDiv).height($('#div'+id).height());
	$(popDiv).width($('#div'+id).width());
	$(document.body).bind("mouseover",function(e) {
		//console.log(e.target.tagName);
		var eventTarget;
		if($.browser.msie){
			eventTarget = e.srcElement;
		}else{
			eventTarget = e.target;
		}
		if(eventTarget.id == 'listButton_popDiv' || $(eventTarget).parents("#listButton_popDiv").length>0 || $(eventTarget).hasClass("overListButton")){
			
		}else{
			$('#div'+id).appendTo("body");
			$('#div'+id).hide();
			$(eventTarget).removeClass("overListButton")
			$("#listButton_popDiv").remove();
			$(document.body).unbind("mouseover");
		}
	})
	
}
function closeFunctionGroup(id,e) {
	//var toolbarWidth = $(".program_toolbar").width();
	//$(".program_toolbar").width(toolbarWidth - $('#div'+id).width());
	//$('#div'+id).hide();
}
function processButton(funcId,functionType,messageType,message){
	${"$('#functionId')"}.val(funcId);
    var url = TDQS.CONTEXT_PATH+'business/process?tdqssid='+TDQS.SESSION_ID+ "&function.id="+${"$('#functionId')"}.val()+"&businessProcess.id="+${"$('#businessProcessId')"}.val()+"&businessInstance.id="+$('#businessInstanceId').val()+"&statistic.id="+"${statistic.id}";
    url += "&date="+new Date().toLocaleString();
	if(!message||message=='') {
	        message = '确定要执行操作吗？';
	}
	if(messageType && messageType=='1') {
	    jConfirm(message, '确认对话框 ', function(r) {  
	    	if(r){
	    		block($('body'),"操作执行中，请稍候...");
                disabledAllButton();
	    		document.location.href = url;
	    	}
		});
	}else{
		block($('body'),"操作执行中，请稍候...");
        disabledAllButton();
   		document.location.href = url;
	}
}
function process(funcId,messageType,message,forwardType,clearSession,isPassParams) {
      ${"$('#functionId')"}.val(funcId);
      var url = TDQS.CONTEXT_PATH+'business/process?tdqssid='+TDQS.SESSION_ID+ "&function.id="+${"$('#functionId')"}.val()+"&businessProcess.id="+${"$('#businessProcessId')"}.val()+"&statistic.id="+$('#statisticId').val();
      <#if statistic.isPassParams?? && statistic.isPassParams=="1">
      	url = url+'&'+$('#hiddenForm').serialize();
      </#if>
      if($('#id').val()!='') {
          url += ("&id="+$('#id').val());
      }
      if('1'==clearSession) {
      	url += "&clearSession=true";
      }
      url += "&date="+new Date().toLocaleString();
      if(!message||message=='') {
            message = '确定要执行操作吗？';
      }
      if(messageType && messageType=='1') {
          jConfirm(message, '确认对话框 ', function(r) {
                        if(r){
                            if(forwardType && forwardType=='2') {
                                executeAjaxFunction(url);
                            } else if(forwardType && forwardType=='4') {
                            	exportData();
                            } else if(forwardType && forwardType=='5') {
                            	importData();
                            }
                            else {
                                document.location.href = url;
                            }
                        }else{
                        	$('#id').val('');
                            return false;
                        }
          });
      }
      else {
            if(forwardType && forwardType=='2') {
                executeAjaxFunction(url);    
            } else if(forwardType && forwardType=='4') {
            	exportData();
            }else if(forwardType && forwardType=='5') {
            	importData();
            } else {
                document.location.href = url;
            }
      }
}
function cancelImport() {
	$.unblockUI();
	$('#fileQueue').remove();
	$('#importUploadify').remove();
}
function downLoadImportFile(fileName) {
	var url = TDQS.CONTEXT_PATH+"/download/downLoadImportFile?filename="+fileName+"&date="+new Date().toLocaleString();
	var frame = document.createElement("iframe");
	frame.src = url;
	frame.style.display = "none";
	document.body.appendChild(frame);
}
function executeImport() {
	$.unblockUI();
	var url = TDQS.CONTEXT_PATH+"business/process?tdqssid="+TDQS.SESSION_ID+ "&function.id="+$('#functionId').val()+"&businessProcess.id="+$('#businessProcessId').val()+"&list.id="+$('#listId').val()+'&'+$('#hiddenForm').serialize();
	$.tdqsAjax({
        type: "post",
        dataType: "json",
        data: $('#importForm').serialize(),
        url: url,
        success:function(json) {
            if(json.data && json.data.type && json.data.type=='2' && json.data.resultData){
            	var message = json.data.resultData;
            	if(message.indexOf(".xls")>-1 || message.indexOf(".xlsx")>-1) {
            		message = "导入文件存在错误的数据，请下载文件后重新修改并导入！<a href=\"javascript:void(0);\" onclick=\"downLoadImportFile('"+encodeURI(message)+"');return false;\">下载</a>";
            	}
                jAlert(message,'提示',function(){
                    $('#GridTable').datagrid("tdqsReload");
                });
            }
            else {
                $('#GridTable').datagrid("tdqsReload");
            }
            ${"$('#id')"}.val('');
            $('#GridTable').datagrid('clearSelections');
            $('input','.datagrid-header-check').each(function(){
                $(this).removeAttr("checked");
            });
        }
    });
	
}

function executeAjaxFunction(url) {
    $.tdqsAjax({
        type: "post",
        dataType: "json",
        url: url,
        success:function(json) {
            if(json.data && json.data.type && json.data.resultData){
                jAlert(json.data.resultData,'提示',function(){
                    $('#GridTable').datagrid("tdqsReload");
                });
            }
            else {
                $('#GridTable').datagrid("tdqsReload");
            }
            ${"$('#id')"}.val('');
            $('#GridTable').datagrid('clearSelections');
            $('input','.datagrid-header-check').each(function(){
                $(this).removeAttr("checked");
            });
        }
    });
}
function processLink(id,funcId,processId,clearSession,fieldId,fieldName,value,entityId) {
	$('#id').val(id);
	var url = TDQS.CONTEXT_PATH+'business/process?tdqssid='+TDQS.SESSION_ID+ "&function.id="+funcId+"&businessProcess.id="+processId+"&list.id="+$('#listId').val();
	if($('#id').val()!='') {
		  url  += ("&paramsMap['id'].value="+$('#id').val());
      }
      if(fieldName && fieldName!='') {
	      url  += ("&paramsMap['"+fieldName+"'].field.id="+fieldId);
		  url  += ("&paramsMap['"+fieldName+"'].value="+value);
		  url  += ("&paramsMap['"+fieldName+"'].entityId="+entityId);
	  }
      if('1'==clearSession) {
      	url += "&clearSession=true";
      }
      url += "&date="+new Date().toLocaleString();
      document.location.href = url;
}
function processCommonFunc(funcId,isBatch,messageType,message,forwardType,clearSession,isPassParams) {
   if(isBatch && isBatch=='1') {
          var select = $('#GridTable').datagrid('getSelections');
          var primaryValue = "";
          var status = "";
          if (select && select != "") {
              for ( var i = 0; i < select.length; i++) {
                  if (i < select.length - 1) {
                       primaryValue += select[i].id+ ",";
                       if(select[i].status && select[i].status.id) {
                       		status += select[i].status.id+ ",";
                       }
                                
                   } else {
                        primaryValue += select[i].id;
                        if(select[i].status && select[i].status.id) {
                       		status += select[i].status.id;
                       }
                   }
               }
           }
           if(!primaryValue || primaryValue=='') {
              jAlert('请选择${businessProcess.businessObj.desc}！','提示',function(){});
              return false;
           }
        $('#id').val(primaryValue);
        $('#status').val(status);
    }
      process(funcId,messageType,message,forwardType,clearSession,isPassParams);
}

function showMenu(){
    
}

var mainLayout;
var centerContentLayout;
var contentLayout;
function layout(){
        var toggle_we        = '<div class="btnToggler_we"></div>'
        , toggle_w            = '<div class="btnToggler_w"></div>'
        , btnToggler_se        = '<div class="btnToggler_se"></div>'
        , btnToggler_s        = '<div class="btnToggler_s"></div>'

        $('body').layout({
            center:{
                paneSelector:    ".center" 
            }
        });
        $(".center").css({"position":"relative"});
        resizeCenter();

        $('div.center').layout({
             center__paneSelector:    ".center_c_c" 
        ,    north__size:    3
        ,    north__paneSelector:    ".center_c_n" 
        ,    north__spacing_open:    0
        ,    north__spacing_closed:    0          
        });
        $(".center_c_n").css({overflow:"hidden"});

		$('div.center_c_c').layout({
			defaults:{
                onresize_end:    resizeDatagrid
                ,onclose_end:    resizeDatagrid  
            }
            ,center:{
                paneSelector:    ".center_c_c_c" 
                ,    spacing_open:    0
                ,    spacing_closed:    0  
            }
            ,north:{
                     paneSelector:    ".center_c_c_n"
                ,    size:    30
                ,    spacing_open:    0
                ,    spacing_closed:    0            
            }
            ,south:{
                     paneSelector:    ".center_c_c_s"
                <#if function_list?? && function_list?size gt 0>
                ,    size:    30
                <#else>
                ,    size:    0
                </#if>
                ,    spacing_open:    0
                ,    spacing_closed:    0    
            } 
         });
        $(".center_c_c_n").css({overflow:"hidden"});
        //$(".center_c_c_c").css({overflow:"hidden"});
   
}

$(window).resize(tabsLayout);
function tabsLayout(){
    $(".ui-tabs-panel-forcalc").css("height",window.document.body.clientHeight-$("#outer_tabs").height() - $("#search_area").height() -$('#tableDiv').height()/2);
    $("#tab_content_div").css("height",230);
    $("#tab_content").css("height",280);
    
}
$(window).resize(function(){
	<#if (statistic.isShowAutoChart?? && statistic.isShowAutoChart=='1')||(statistic.chartType?? && statistic_data_chart??)||(statistic.statisticType?? && statistic.statisticType=='2')>
	</#if>
		$("#chartDiv #container").css("height",window.document.body.clientHeight-$(".serverErrorContainer").height()-40-30-2-${menuDivNumber*34});
		if($.browser.msie&&($.browser.version == "6.0")){
			$("#chartDiv #container").css("width",window.document.body.clientWidth-scrollBarWidth);
		}

	$("#tableDiv").css("height",window.document.body.clientHeight-$(".serverErrorContainer").height()-40-30-2-${menuDivNumber*34});
	if($.browser.msie&&($.browser.version == "6.0")){
		$("#tableDiv").css("width",window.document.body.clientWidth-scrollBarWidth);
	}
	$("#search_area").css('top',$("#outer_tabs").height());
	resizeCenter();
	resizeDatagrid();
});
function contentLayout(){
	<#if (statistic.isShowAutoChart?? && statistic.isShowAutoChart=='1')||(statistic.chartType?? && statistic_data_chart??)||(statistic.statisticType?? && statistic.statisticType=='2')>
	</#if>
		$("#chartDiv #container").css("height",window.document.body.clientHeight-$(".serverErrorContainer").height()-40-30-2-${menuDivNumber*34});
		if($.browser.msie&&($.browser.version == "6.0")){
			$("#chartDiv #container").css("width",window.document.body.clientWidth-scrollBarWidth);
		}
		
	$("#tableDiv").css("height",window.document.body.clientHeight-$(".serverErrorContainer").height()-40-30-2-${menuDivNumber*34});
	if($.browser.msie&&($.browser.version == "6.0")){
		$("#tableDiv").css("width",window.document.body.clientWidth-scrollBarWidth);
	}
	resizeCenter();
	resizeDatagrid();
}

function resizeCenter(){
	<#if !statistic.isTree?? || statistic.isTree == "0">
		<#if statistic_list??>
		$(".center").css("top",$("#outer_tabs").height() + $("#search_area").height());
		<#else>
		$(".center").css("top", $("#search_area").height());
		</#if>
	</#if>  
	tabsLayout();  
}
var resizeDataGrid=false;
function resizeDatagrid(){
	//alert("resizeDatagrid()-----" + resizeDataGrid);
	<#if !statistic.isTree?? || statistic.isTree == "0">
		<#if statistic_list??>
		$(".center").css("top",$("#outer_tabs").height() + $("#search_area").height());
		<#else>
		$(".center").css("top", $("#search_area").height());
		</#if>
	</#if> 
	if(resizeDataGrid){
		$('#statisticGridTable').datagrid("autoresize",{rh:$(".center_c_c_s").height()});
		//+tabdivFixHeight});
	}
	<#if statistic_data_title_list??>
	</#if>
}
</script>